package com.chinatelecom.telecollege.sellerrewarding.service;

import com.chinatelecom.telecollege.sellerrewarding.Entity.crmorder;
import com.chinatelecom.telecollege.sellerrewarding.repository.crmorderRepo;
import com.chinatelecom.telecollege.sellerrewarding.Entity.product;
import com.chinatelecom.telecollege.sellerrewarding.Entity.sellorder;
import com.chinatelecom.telecollege.sellerrewarding.Entity.servicehall;
import com.chinatelecom.telecollege.sellerrewarding.Entity.area;
import com.chinatelecom.telecollege.sellerrewarding.Entity.seller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by lenovo on 2017/6/21.
 */
@Service
public class crmorderService {
    @Autowired
    private crmorderRepo crmorderRepo;

    @Transactional
    public List<crmorder> findAll() {
        List<servicehall> servicehalls = new servicehallService().findAll();
        Map<Integer,servicehall> mservicehalls = new HashMap<Integer, servicehall>();
        for(servicehall e:servicehalls)  mservicehalls.put(e.getId(),e);
        List<area> areas = new areaService().findAll();
        List<sellorder> sellorders = new sellorderService().findAll();
        List<product> products = new productService().findAll();


        return crmorderRepo.findAll();
    }
    public crmorder findByid(int id) {
        return crmorderRepo.findOne(id);
    }
    public List<crmorder> findByseller(String operatorphone) {
        return crmorderRepo.findByoperatorphone(operatorphone);
    }
    public List<crmorder> findByarea(int idarea) {
        return crmorderRepo.findByidarea(idarea);
    }
    public List<crmorder> findByservicehall(int idservicehall) {
        return crmorderRepo.findByidservicehall(idservicehall);
    }
    public void save(String operatorphone, String date, int id_servicehall, int id_area, String name, String phone, int id_product) {
        crmorder crmorder = new crmorder();
        crmorder.setOperatorphone(operatorphone);
        crmorder.setDate(date);
        crmorder.setIdservicehall(id_servicehall);
        crmorder.setIdarea(id_area);
        crmorder.setName(name);
        crmorder.setPhone(phone);
        crmorder.setIdproduct(id_product);
        crmorderRepo.save(crmorder);
    }
}
class crmorderServiceComb {
    
}
